import http from '../utils/request'
import http1 from '../utils/realrequest'



//请求首页数据
export const getData = ()=>{
    //返回一个Promise对象
    return http.get('/home/getData')
}

export const getUser = () =>{
    return http.get('/user/getUser')
}

export const addUser = (data) =>{
    return http.post('/user/addUser',data)
}


export const updateUser = (data) =>{
    return http.post('/user/updateUser',data)
}


export const deleteUser = (data) =>{
    return http.post('/user/deleteUser',data)
}

//获取分页数据
export const getRealUser = (pageSize,currentPage) =>{
    return http1.get(`/user/${pageSize}/${currentPage}`)
}

//新增用户
export const addRealUser = (data) =>{
    return http1.post('/user',data)
}

//删除用户
export const deleteRealUser = (data) => {
    return http1.delete(`/user/${data}`)
}

//更新用户
export const updateRealUser = (data) =>{
    return http1.put('/user',data)
}

//登录
export const adminLogin = (data) => {
    return http1.post('/api/login',data)
}

//获取管理员用户信息
export const getAdminInfo = () => {
    return http1.get('api/adminInfo')
}

//修改头像
export const updateAvatar = (picUrl) => {
    return http1.patch(`api/updateAvatar?picUrl=${encodeURIComponent(picUrl)}`);
}

//修改管理员主要信息
export const updateAdminInfo = (data) => {
    return http1.put('api/update',data)
}

//修改管理员密码
export const updatePwd = (data) => {
    return http1.patch('api/updatePwd',data)
}